package cn.edu.qvtu.rj231.lms03;

import cn.edu.qvtu.rj231.lms01.Callback;
import cn.edu.qvtu.rj231.lms01.Employee;
import cn.edu.qvtu.rj231.lms02.EmployeeDAO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service//声明为业务处理类
public class EmployeeService {
    @Autowired //注入对象（组件）
    private EmployeeDAO dao;

    public Callback add(Employee emp){
        emp.setId(System.currentTimeMillis());
        if(dao.add(emp)==1){
            return new Callback(true,"添加成功");
        }
        return new Callback(false,"添加失败");
    }

    public Callback del(long id){
        if (dao.del(id)==1){
            return new Callback(true,"删除成功");
        }
        return new Callback(false,"删除失败");
    }
}
